package com.roc.androidlive;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;

import com.roc.androidlive.receiver.MyReceiver;

public class App extends Application {

    private static Context instance;

    public static Context getContext() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        Log.d("App", "the code is run in Application!");

        MyReceiver receiver = new MyReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
        intentFilter.addAction(Intent.ACTION_REBOOT);
        intentFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);//锁屏
        intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);//方向发生变化
//        intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");

        registerReceiver(receiver, intentFilter);
    }
}
